package com.sailfish.springbootdemo.controller.db1;

import com.sailfish.springbootdemo.pojo.Result;
import com.sailfish.springbootdemo.pojo.db1.PcbaLineRelatedDevice;
import com.sailfish.springbootdemo.service.db1.PcbaLineRelatedDeviceService;
import com.sailfish.springbootdemo.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping("/pcbaLineRelatedDeviceResource")
public class PcbaLineRelatedDeviceController {

    /*@Autowired
    private PcbaLineRelatedDeviceService pcbaLineRelatedDeviceService;

    @PostMapping("/getAllByLine")
    public Result getAllByLine(Integer pcbaLineId){
        try{
            if(pcbaLineId == null || "".equals(pcbaLineId.toString())){
                return ResultUtil.error(500, "缺少参数pcbaLineId", "Miss Param pcbaLineId", null);
            }
            return ResultUtil.success(pcbaLineRelatedDeviceService.getAllByLine(pcbaLineId));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/deleteByLineAndDevice")
    public Result deleteByLineAndDevice(Integer pcbaLineId,Integer pcbaDeviceId){
        return pcbaLineRelatedDeviceService.deleteByLineAndDevice(pcbaLineId, pcbaDeviceId);
    }

    @PostMapping("/updatePcbaLineRelatedDeviceAndPcbaLine")
    public Result updatePcbaLineRelatedDeviceAndPcbaLine(PcbaLineRelatedDevice pcbaLineRelatedDevice, String lastUpkeepTimeStr){
        return pcbaLineRelatedDeviceService.updatePcbaLineRelatedDeviceAndPcbaLine(pcbaLineRelatedDevice, lastUpkeepTimeStr);
    }

    @PostMapping("/getPcbaLineRelatedDeviceById")
    public Result getPcbaLineRelatedDeviceById(Integer pcbaLineRelatedDeviceId){
        try{
            if(pcbaLineRelatedDeviceId == null || "".equals(pcbaLineRelatedDeviceId.toString())){
                return ResultUtil.error(500, "缺少参数pcbaLineRelatedDeviceId", "Miss Param pcbaLineRelatedDeviceId", null);
            }
            return ResultUtil.success(pcbaLineRelatedDeviceService.getPcbaLineRelatedDeviceById(pcbaLineRelatedDeviceId));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }*/

}
